const requireEx=require('yi-require');

const middleware = (req,res,next)=>{
    let filter = req.query.filter||{};
    let sort = req.query.sort||{};
    if(filter.careID){
        filter['authorID'] = {"$in":filter.careID};
        delete filter.careID;
    }
    if(filter.search){
        filter['title'] = {"$regex":filter.search};
        delete filter.search;
    }
    if(!sort.createTime){
        req.query['sort']= {createTime:-1};
    }
    next();
};


module.exports = {
    open:false,
    description:'获取关注',
    middleware:middleware,
    handler: requireEx('yi-restful').r('card')
};


